home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / CocktailManager / CoctailManager.jar / Coctail.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-07  |  2.2 KB  |  67 lines

  1. public class Coctail {
  2.    private String name;
  3.    private String ingredients;
  4.    private String recipe;
  5.    private int userScore = 0;
  6.  
  7.    public Coctail(String name, String ingredients, String recipe) {
  8.       this.name = name;
  9.       this.ingredients = ingredients;
  10.       this.recipe = recipe;
  11.    }
  12.  
  13.    public String getName() {
  14.       return this.name;
  15.    }
  16.  
  17.    public String getIngredients() {
  18.       return this.ingredients + '\n';
  19.    }
  20.  
  21.    public String getRecipe() {
  22.       return this.recipe + '\n';
  23.    }
  24.  
  25.    public void setScore(int score) {
  26.       this.userScore = score;
  27.    }
  28.  
  29.    public int getScore() {
  30.       return this.userScore;
  31.    }
  32.  
  33.    public String createCoctailSMS() {
  34.       StringBuffer coctail = new StringBuffer();
  35.       coctail.append(this.getName()).append('\n');
  36.       coctail.append(CoctailDatabase.getString(10) + ": ").append(this.getIngredients()).append('\n');
  37.       coctail.append(CoctailDatabase.getString(11) + ": ").append(this.getRecipe()).append('\n');
  38.       return coctail.toString().trim();
  39.    }
  40.  
  41.    public String createCoctailDisplay() {
  42.       StringBuffer coctail = new StringBuffer();
  43.       coctail.append(CoctailDatabase.getString(10) + ": ").append(this.getIngredients()).append('\n');
  44.       coctail.append(CoctailDatabase.getString(11) + ": ").append(this.getRecipe()).append('\n');
  45.       return coctail.toString().trim();
  46.    }
  47.  
  48.    public String createCoctailXML() {
  49.       StringBuffer coctail = new StringBuffer();
  50.       coctail.append("<cocktail>");
  51.       coctail.append("<name>").append(this.getName()).append("</name>");
  52.       coctail.append("<ingredients>").append(this.getIngredients()).append("</ingredients>");
  53.       coctail.append("<recipe>").append(this.getRecipe()).append("</recipe>");
  54.       coctail.append("</cocktail>");
  55.       return coctail.toString();
  56.    }
  57.  
  58.    public String createScoreXML() {
  59.       StringBuffer coctail = new StringBuffer();
  60.       coctail.append("<cocktail>");
  61.       coctail.append("<name>").append(this.getName()).append("</name>");
  62.       coctail.append("<score>").append(this.getScore()).append("</score>");
  63.       coctail.append("</cocktail>");
  64.       return coctail.toString();
  65.    }
  66. }
  67.